﻿Imports System.Web
Imports System.ServiceModel

Namespace DotNetNuke.Modules.IWebCF
    Public Class IWebContractAttribute
        Inherits Attribute

        Private _binding As String = String.Empty
        Private _bindingConfiguration As String = String.Empty
        Private _address As String = String.Empty
        Private _name As String = String.Empty


        Public Sub New(ByVal Binding As CoreBindings)

           
            Me.SetBindingConfiguration(Binding)

        End Sub


        Public Property Address() As String
            Get
                Return _address
            End Get
            Set(ByVal value As String)
                _address = value
            End Set
        End Property
        Public Property Binding() As String
            Get
                Return _binding
            End Get
            Set(ByVal value As String)
                _binding = value
            End Set
        End Property

        Public Property BindingConfiguration() As String
            Get
                Return _bindingConfiguration
            End Get
            Set(ByVal value As String)
                _bindingConfiguration = value
            End Set
        End Property

        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property

        Private Sub SetBindingConfiguration(ByVal Binding As CoreBindings)
            Select Case Binding

                Case CoreBindings.mexHttpBinding

                    Me.Binding = Binding.ToString

                    Me.BindingConfiguration = CoreBindingConfigurations.MexHttpBinding


                Case CoreBindings.ws2007HttpBinding

                    Me.Binding = Binding.ToString

                    Me.BindingConfiguration = CoreBindingConfigurations.Ws2007Binding

                Case CoreBindings.mtomHttpBinding

                    Me.Binding = CoreBindings.basicHttpBinding.ToString

                    Me.BindingConfiguration = CoreBindingConfigurations.MtomHttpBinding

                Case CoreBindings.basicHttpBinding
                    Me.Binding = Binding.ToString

                    Me.BindingConfiguration = CoreBindingConfigurations.BasicHttpBinding


                Case Else

                    Me.Binding = Binding.ToString

                    Me.BindingConfiguration = CoreBindingConfigurations.DefaultBinding

            End Select
        End Sub


    End Class
End Namespace
